package com.zenithsun.news.statistics.controller;

import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import com.syzg.common.model.WebObj;
import com.zenithsun.news.newsinfo.service.NewsinfoService;
import com.zenithsun.news.statistics.service.StatisticsService;

@Controller
@RequestMapping("/statistics")
public class StatisticsController {
	
    static Logger log = LoggerFactory.getLogger(StatisticsController.class);
    
    @Resource
	private NewsinfoService newsinfoService;
    
	@Resource
	private StatisticsService statisticsService;
	
	/*
	 * 按栏目统计新闻总量
	 */
    @RequestMapping("/columnsNewsCounter")
    public ModelAndView columnsNewsCounter(WebObj webObj)throws Exception{
    	ModelAndView mv = new ModelAndView("/zenithsun/news/statistics/columnsNewsCounter.jsp");
    	List<HashMap<String,Object>>result = statisticsService.listColumnsNewsCounter();
    	mv.addObject("result",result);
		return mv;
    }
    
    /*
     * 
     */
    @RequestMapping(value="/newsCounter", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String newsCounter() throws Exception {
	    List<HashMap<String,Object>>result = statisticsService.listColumnsNewsCounter();
		return JSON.toJSONString(result);
    }
    
	/*
	 * 栏目下的新闻浏览量
	 */
    @RequestMapping("/columnsViewCounter")
    public ModelAndView columnsViewCounter(WebObj webObj)throws Exception{
    	ModelAndView mv = new ModelAndView("/zenithsun/news/statistics/columnsViewCounter.jsp");
    	List<HashMap<String,Object>>result = statisticsService.listColumnsNewsPVCounter();
    	mv.addObject("result",result);
		return mv;
    }
    
    @RequestMapping(value="/columnsNewsPVCounter", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String columnsNewsPVCounter() throws Exception {
	    List<HashMap<String,Object>>result = statisticsService.listColumnsNewsPVCounter();
		return JSON.toJSONString(result);
    }
    
	/*
	 * 每日新闻总浏览量
	 */
    @RequestMapping("/newsDailyPageViews")
    public ModelAndView newsDailyPageViews(WebObj webObj)throws Exception{
    	ModelAndView mv = new ModelAndView("/zenithsun/news/statistics/newsDailyPageViews.jsp");
    	List<HashMap<String,Object>>result = statisticsService.listNewsDailyPVCounter();
    	mv.addObject("result", result);
		return mv;
    }
    
    @RequestMapping(value="/NewsDailyPVCounter", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String NewsDailyPVCounter() throws Exception {
	    List<HashMap<String,Object>>result = statisticsService.listNewsDailyPVCounter();
		 return JSON.toJSONString(result);
    }
    
    /*
	 * 每月新闻总浏览量
	 */
    @RequestMapping("/newsMonthlyPV")
    public ModelAndView newsMonthlyPV(WebObj webObj)throws Exception{
    	ModelAndView mv = new ModelAndView("/zenithsun/news/statistics/newsMonthlyPV.jsp");
    	List<HashMap<String,Object>>result = statisticsService.listNewsMonthPVCounter();
    	mv.addObject("result", result);
		return mv;
    }
    
    @RequestMapping(value="/NewsMonthlyPVCounter", produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String NewsMonthlyPVCounter() throws Exception {
	    List<HashMap<String,Object>>result = statisticsService.listNewsMonthPVCounter();
		 return JSON.toJSONString(result);
    }
}
